<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript" src="<c:url value="js/jquery-easyui-1.5.4.2/jquery.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="js/jquery-easyui-1.5.4.2/jquery.easyui.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="js/jquery-easyui-1.5.4.2/locale/easyui-lang-zh_CN.js"/>"></script>
<link id="theme" rel="stylesheet" type="text/css"  href="<c:url value="js/jquery-easyui-1.5.4.2/themes/ui-cupertino/easyui.css"/>"/>
<link  rel="stylesheet" type="text/css" href="<c:url value="js/jquery-easyui-1.5.4.2/themes/icon.css"/>"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合同</title>
</head>
<body>
<script type="text/javascript">
function formattime(val) {
	var unixTimestamp = new Date(val);
    return unixTimestamp.toLocaleString();  
}
</script>
<div id="contract_panel_yj" class="easyui-panel" data-options="fit:true,border:false">
	<table id="contract_yj_table" class="easyui-datagrid" data-options="
				fitColumns:true,
				fit:true,
				singleSelect:true,
				newrap:true,
				rownumbers:true,
				pagination:true,
				pageList:[5,10,15,20],
				pageSize:5,
				toolbar:'#toolbar1',
				border:false,
				url:'find-contract_all_yj'
				">
			<thead>
				<tr>
					<th data-options="field:'CONAD_ID',width:110,align:'center'">合同电建</th>
					<th data-options="field:'STAIN_ID',width:110,align:'center'">员工编号</th>
					<th data-options="field:'STAIN_NAME',width:110,align:'center'">员工名称</th>
					<th data-options="field:'CONAD_CONTENT',width:110,align:'center'">合同内容</th>
					<th data-options="field:'CONCA_NAME',width:110,align:'center'">合同类别</th>
					<th data-options="field:'CONAD_TRYOUTENDTIME',width:150,align:'center',formatter:function (value,rec,index) {
					return formattime(value);
					}">试用结束日期</th>
					<th data-options="field:'CONAD_TERM',width:110,align:'center',formatter: function (value, rec, index) {
                       return formattime(value);
					}">合同日期</th>
					<th data-options="field:'CONAD_STARTTIME',width:110,align:'center',formatter: function (value, rec, index) {
      					  return formattime(value);
					}">开始日期</th>
					<th data-options="field:'CONAD_ENDTIME',width:110,align:'center',formatter: function (value, rec, index) {
      					  return formattime(value);
					}">结束日期</th>
					
				</tr> 
			</thead>
			<tbody>
			</tbody>
		</table>
		<div  id="toolbar1"  >
					<a href="#" id="contract_insert_yj" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true,text:'新增',iconAlign:'left'"></a>| 
                <a href="#" id="contract_update_yj" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true,text:'编辑',iconAlign:'left'"></a>| 
                <a href="#" id="contract_delete_yj" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true,text:'删除',iconAlign:'left'"></a>| 
				<input id="contract_searchbox_yj" class="easyui-textbox"  data-options="iconCls:'icon-search'" style="width:200px"> 
				<a class="easyui-linkbutton contract_search_yj" iconCls="icon-remove" plain="true">搜索</a>
				
		</div>
		
		
		
</div>
	<script type="text/javascript">
		$(function() {
			var all_out_layout = function(texttitle) {
				$(".add_success_ok").text(texttitle).prop(texttitle);
				$(".all_out_layout").panel("open");
				window.setInterval(function() {
					$(".all_out_layout").panel("close");
				}, 2000);
			};

			//搜索
			$(".contract_search_yj").linkbutton(
					{
						onClick : function() {
							var name = $("#contract_searchbox_yj").textbox(
									"getText");
							$("#contract_yj_table").datagrid('load',
									'findlike-contract_all_yj?name=' + name);
							$("#contract_searchbox_yj").textbox("setText", "");
						}
					});

			//新增打开页面
			$("#contract_insert_yj").linkbutton({
				onClick : function() {
					$("#contract_panel_yj").panel({
						href : 'to_contract_insert_yj'
					});
				}
			});
			
			//删除合同信息
			$("#contract_delete_yj").linkbutton({
				onClick:function(){
					var table = $("#contract_yj_table").datagrid("getSelected");
					if(table==null){
						all_out_layout("请选择要删除的合同")
					}else{
						var id = table.CONAD_ID;
						$.getJSON("delete_contract_admin_yj",{"id":id},function(v){
							if(v){
								$("#contract_yj_table").datagrid("reload");    
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						});
					}
				}
			});
			//修改
			$("#contract_update_yj").linkbutton({onClick:function(){
				var table = $("#contract_yj_table").datagrid("getSelected");
				if(table==null){
					all_out_layout("请选择要编辑的合同")
				}else{
					var id = table.CONAD_ID;
					$("#contract_panel_yj").panel({
						href : 'to_contract_update_yj?id='+id
					});
				}
			}});

		});
	</script>
</body>
</html>